#include <stdio.h>
#include <string.h>

int f, k;
bool plant[10005];
int ans;
bool init()
{
    if (scanf("%d%d", &f, &k)==EOF) return false;
    return true;
}    
void deal()
{
    int st, add, i;
    memset(plant, 0, sizeof(plant));
    ans = 0;
    while (k--)
    {
        scanf("%d%d", &st, &add);
        while (st<=f)
        {
            plant[st] = true;
            st += add;
        }            
    }    
    for (i=1; i<=f; ++i)
       if (!plant[i]) ans++;
    printf("%d\n", ans);
}    

int main()
{
    while (init())
    {
        deal();    
    }        
    return 0;    
}    

